import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import HomeMainView from '../views/HomeMainView.vue'
import NotFoundView from '../views/NotFoundView.vue'
import SubpageMainView from '../views/SubpageMainView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      redirect: '/homeMain',
      children: [
        {
          path: 'homeMain',
          name: 'homeMain',
          component: HomeMainView,
        },
        {
          path: '/search/:key',
          name: 'search',
          component: SubpageMainView,
        },
      ],
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'NotFound',
      component: NotFoundView,
    },
  ],
})

export default router
